package database

import (
	"sync"

	_ "github.com/glebarez/sqlite"
	"xorm.io/xorm"
)

var (
	engine *xorm.Engine
	once   sync.Once
)

func Get() *xorm.Engine {
	once.Do(func() {
		var err error
		engine, err = xorm.NewEngine("sqlite", "./db.sqlite")
		if err != nil {
			panic(err)
		}
	})
	return engine
}
